<?php

class Model_usersession extends MY_Model {

	function __construct() {
		parent::__construct();
	}

	/**
	 * Aduce sesiunile active pentru userul $iUserId
	 * @return array
	 * @param int $iUserId
	 */
	function getSession($iUserId) {
		$oQuery = $this->db->get_where("cisession", array("user_id" => $iUserId));
		$aResult = array();
		if ($oQuery->num_rows() > 0) {
			foreach ($oQuery->result_array() as $row) {
				$aResult[] = $row['session_id'];
			}
		}
		return $aResult;
	}

	/**
	 * Update pe sesiune
	 * @return void
	 * @param string $sSessionId
	 * @param int $iUserId
	 */
	function insertSession($sSessionId, $iUserId) {
		$this->db->where('session_id', $sSessionId);
		$this->db->update('cisession', array('user_id' => $iUserId));
	}

	/**
	 * Stergere sesiune utilizator
	 * @param int $iUserId
	 * @return void
	 */
	function deleteSession($iUserId) {
		$this->db->where("user_id", $iUserId);
		$this->db->delete("cisession");
	}
}

/* End of file Model_usersession.php */
/* Location: ./system/application/models/model_usersession.php */
?>